Definition:
- Test methods need to be simple and execute all statements in the production method. Conditions within the test method will alter the behavior of the test and its expected output, and would lead to situations where the test fails to detect defects in the production method since test statements were not executed as a condition was not met. Furthermore, conditional code within a test method negatively impacts the ease of comprehension by developers.
Also Known As:
- Indented Test Code, Guarded Test
Code Example:
@Test
public void testSpinner() {
for (Map.Entry entry : sourcesMap.entrySet()) {
String id = entry.getKey();
Object resultObject = resultsMap.get(id);
if (resultObject instanceof EventsModel) {
EventsModel result = (EventsModel) resultObject;
if (result.testSpinner.runTest) {
System.out.println("Testing " + id + " (testSpinner)");
//System.out.println(result);
AnswerObject answer = new AnswerObject(entry.getValue(), "", new CookieManager(), "");
EventsScraper scraper = new EventsScraper(RuntimeEnvironment.application, answer);
SpinnerAdapter spinnerAdapter = scraper.spinnerAdapter();
assertEquals(spinnerAdapter.getCount(), result.testSpinner.data.size());
for (int i = 0; i < spinnerAdapter.getCount(); i++) {
assertEquals(spinnerAdapter.getItem(i), result.testSpinner.data.get(i));
}
}
}
}
}
References:
Quality attributes
- :octicon:`file-code;1em` - Code Example
- :octicon:`comment-discussion;1em` - Cause and Effect
- :octicon:`graph;1em` - Frequency
- :octicon:`sync;1em` - Refactoring
- A survey on test practitioners' awareness of test smells
- An Exploratory Study on the Refactoring of Unit Test Files in Android Applications :octicon:`comment-discussion;1em` :octicon:`sync;1em`
- Anti-patterns of automated testing
- Automatic Identification of High-Impact Bug Report by Product and Test Code Quality
- Automatic generation of smell-free unit tests :octicon:`comment-discussion;1em`
- Categorising Test Smells :octicon:`graph;1em`
- Detection of test smells with basic language analysis methods and its evaluation :octicon:`comment-discussion;1em` :octicon:`graph;1em`
- Did You Remember To Test Your Tokens? :octicon:`comment-discussion;1em`
- Enhancing developers’ awareness on test suites’ quality with test smell summaries
- Handling Test Smells in Python: Results from a Mixed-Method Study
- How are test smells treated in the wild? A tale of two empirical studies :octicon:`graph;1em`
- Hunting for smells in natural language tests :octicon:`comment-discussion;1em` :octicon:`graph;1em`
- Improving Student Testing Practices through a Lightweight Checklist Intervention. :octicon:`file-code;1em` :octicon:`comment-discussion;1em` :octicon:`graph;1em`
- Inspecting Automated Test Code: A Preliminary Study :octicon:`graph;1em`
- Investigating Severity Thresholds for Test Smells :octicon:`comment-discussion;1em`
- Investigating Test Smells in JavaScript Test Code :octicon:`graph;1em`
- On the Distribution of "Simple Stupid Bugs" in Unit Test Files: An Exploratory Study
- On the diffusion of test smells and their relationship with test code quality of Java projects :octicon:`graph;1em`
- On the distribution of test smells in open source Android applications: an exploratory study :octicon:`file-code;1em` :octicon:`graph;1em`
- On the influence of Test Smells on Test Coverage
- On the test smells detection: an empirical study on the jnose test accuracy :octicon:`graph;1em`
- On the use of test smells for prediction of flaky tests :octicon:`comment-discussion;1em` :octicon:`graph;1em`
- PyNose: A Test Smell Detector For Python :octicon:`comment-discussion;1em` :octicon:`graph;1em`
- Pytest-Smell: a smell detection tool for Python unit tests :octicon:`graph;1em`
- Refactoring Test Smells With JUnit 5: Why Should Developers Keep Up-to-Date? :octicon:`file-code;1em` :octicon:`comment-discussion;1em` :octicon:`graph;1em` :octicon:`sync;1em`
- Refactoring Test Smells: A Perspective from Open-Source Developers :octicon:`file-code;1em` :octicon:`sync;1em`
- Rule-based Assessment of Test Quality :octicon:`graph;1em`
- Smart prediction for refactorings in the software test code :octicon:`graph;1em`
- Software Unit Test Smells :octicon:`file-code;1em`
- TEMPY: Test Smell Detector for Python :octicon:`graph;1em`
- Test Smell Detection Tools: A Systematic Mapping Study
- Test code quality and its relation to issue handling performance :octicon:`comment-discussion;1em`
- TestAXE: Automatically Refactoring Test Smells Using JUnit 5 Features :octicon:`graph;1em` :octicon:`sync;1em`
- The secret life of test smells-an empirical study on test smell evolution and maintenance :octicon:`graph;1em`
- Toward static test flakiness prediction: a feasibility study :octicon:`graph;1em`
- Understanding Testability and Test Smells
- Understanding practitioners’ strategies to handle test smells: a multi-method study :octicon:`comment-discussion;1em` :octicon:`sync;1em`
- Unit Test Smells and Accuracy of Software Engineering Student Test Suites
- What the Smell? An Empirical Investigation on the Distribution and Severity of Test Smells in Open Source Android Applications :octicon:`file-code;1em` :octicon:`graph;1em`
- tsDetect: an open source test smells detection tool
- xUnit test patterns: Refactoring test code :octicon:`file-code;1em` :octicon:`comment-discussion;1em` :octicon:`sync;1em`
- xUnit test patterns: Refactoring test code :octicon:`file-code;1em` :octicon:`comment-discussion;1em` :octicon:`sync;1em`